<?php $this->load->view('header');?>
<style>
.labinu{
	line-height:36px;
}
</style>
<body class="childrenBody custom_body">
	<div class="custom_main">
		<fieldset class="layui-elem-field layui-field-title">
		  <legend>详细</legend>
		</fieldset>
		
		<form class="layui-form">
			<div class="layui-form-item">
				<label class="layui-form-label">课程：</label>
				<div class="layui-input-block labinu">				
					<?=$course_name?>
				</div>
			</div>		
			<div class="layui-form-item">
				<label class="layui-form-label">会员：</label>
				<div class="layui-input-block labinu">				
					<?=$user_name?>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">会员卡：</label>
				<div class="layui-input-block labinu">				
					<?=$card_name?>
				</div>
			</div>
			<!--div class="layui-form-item">
				<label class="layui-form-label">订单号：</label>
				<div class="layui-input-block labinu">				
					<?=$order_sn?>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">流水号：</label>
				<div class="layui-input-block labinu">				
					<?=$transaction_id?>
				</div>
			</div-->
			<div class="layui-form-item">
				<label class="layui-form-label">总次数：</label>
				<div class="layui-input-block labinu">				
					<?=$total_num?>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">剩余次数：</label>
				<div class="layui-input-block labinu">				
					<?=$num?>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">价格：</label>
				<div class="layui-input-block labinu">				
					<?=$price?>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">购买时间：</label>
				<div class="layui-input-block labinu">				
					<?=$addtime?>
				</div>
			</div>
			
		</form>
	</div>

	<script type="text/javascript">
		layui.config({
			version: true
		}).use(['jquery','layer', 'form', 'laytpl', 'upload', 'element','layedit'],function(){
			var form = layui.form,
				layer = parent.layer === undefined ? layui.layer : parent.layer,
				laypage = layui.laypage,
				laytpl = layui.laytpl,
				upload = layui.upload,
				layedit = layui.layedit,
				element = layui.element,
				$ = layui.jquery;

			var _edit = <?=$edit_sport?>;//动作数据

			var image_upload = '<?=$image_upload_url?>';
				//自定义验证规则  
				// form.verify({ 
				// 	checkboxmustbe: function(){  
				// 		if (!$("#sport").is(":checked")) {
				// 			return "必须选择包含动作";
				// 		}
			 //        }
				// }); 

			//上传图片
			var uploadInst = upload.render({
			    elem: '#test1'
			    ,url: image_upload
			    ,before: function(obj){
			      //预读本地文件示例，不支持ie8
			      obj.preview(function(index, file, result){
			        $('#demo1').attr('src', result); //图片链接（base64）
			        $("#demo1").css("width","100px");
			      });
			    }
			    ,done: function(res){
			      //如果上传失败
			      if(res.result_code > 0){
			        return layer.msg('上传失败');
			      } 
			      //上传成功
			      else{
			      	$("input[name='theme_img']").val(res.data[0].url);
			      }
			     
			    }
			    ,error: function(){
			      //演示失败状态，并实现重传
			      var demoText = $('#demoText');
			      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
			      demoText.find('.demo-reload').on('click', function(){
			        uploadInst.upload();
			      });
			    }
			  });

			//选中已选择的动作
			layui.each(_edit, function(index, el) 
			{
				var child = $('.layui-form').find('input[type="checkbox"][value="'+el+'"]');
				child.each(function(i, item){ 
					item.checked = true;
			    });
			});


			  //构建一个默认的编辑器
			  var index = layedit.build('LAY_demo1',{
			  	tool: ['strong','italic','underline','del','|','left','center','right','link','unlink']
			  });

				//提交表单
				form.on("submit(addUser)",function(data)
				{
					data.field['content'] = layedit.getContent(index); //详情简介

					$.post('admin.php/Order/insert', data.field, function(result) 
					{
						if (result.status == 200) 
						{
							layer.msg(result.message, {icon: 1});
							location.reload();
						}
						else
						{
							layer.msg(result.message, {icon: 5});
						}

					},"json");

					return false;
				});

				form.render(); //更新全部

		});

	</script>

</body>
</html>